﻿namespace MelodysDemo.Application.AppServices
{
    public static class PwdEncryption
    {
        /// <summary>
        /// 哈希加密
        /// </summary>
        /// <param name="password"></param>
        /// <returns>单向加密，只进行加密，不进行解密，每次判断都是比较加密后的数据</returns>
        public static string HashPassword(string password)
        {
            using (var sha256 = SHA256.Create())
            {
                byte[] bytes = sha256.ComputeHash(Encoding.UTF8.GetBytes(password));
                return BitConverter.ToString(bytes).Replace("-", "").ToLower();
            }
        }
    }
}
